/***************************************************************************
 *   Copyright (C) 2008 by Eduardo Gurgel Pinho                            *
 *   edgurgel@gmail.com                                                    *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 3 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
***************************************************************************/

#include "main_widget.h"

#include "image_widget.h"

#include <QPixmap>
#include <QImage>
#include <QLabel>
#include <QScrollArea>
#include <QVBoxLayout>
#include <QMouseEvent>

namespace Ui {

Main_Widget::Main_Widget(QWidget* parent) : QWidget(parent) {
	image_widget = new Image_Widget(this);
	
	QScrollArea* scroll_area = new QScrollArea(this);
	scroll_area->setBackgroundRole(QPalette::Dark);
	scroll_area->setWidget(image_widget);
	
	QVBoxLayout* box = new QVBoxLayout(this);
	box->addWidget(scroll_area);
	
	setLayout(box);
	
	
	setMinimumSize(400,400);
}



Main_Widget::~Main_Widget(void) {
	delete image_widget;
}
 
Image_Widget* Main_Widget::get_image(void) { 
	return image_widget;
}

void Main_Widget::clear(void) {
	image_widget->clear();
}

void Main_Widget::show_image(QImage* _qimage) {
	if(_qimage != 0) {
		image_widget->setPixmap(QPixmap::fromImage(*_qimage));
		image_widget->adjustSize();
	}
}


}
